package com.ccepc.algmanage.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ccepc.algmanage.service.RemoteHistoryService;
import com.ccepc.common.core.util.R;
import com.ccepc.common.log.annotation.SysLog;
import com.ccepc.demo.api.entity.RemoteHistory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 *
 *
 * @author pigx code generator
 * @date 2023-11-02 15:49:01
 */
@RestController
@RequestMapping("/remotehistory" )
@Api(value = "remotehistory", tags = "联动设备远程控制")
public class RemoteHistoryController {

    @Resource
    private RemoteHistoryService remoteHistoryService;

    @ApiOperation(value = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('algmanage_remotehistory_view')" )
    public R getRemoteHistoryPage(Page<RemoteHistory> page, RemoteHistory remoteHistory) {
        return R.ok(remoteHistoryService.page(page, Wrappers.query(remoteHistory).orderByDesc("act_time")));
    }

    @ApiOperation(value = "新增")
    @SysLog("新增" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('algmanage_remotehistory_add')" )
    public R save(@RequestBody RemoteHistory remoteHistory) {
        return R.ok(remoteHistoryService.historySave(remoteHistory));
    }

}
